package com.yeyks.controller.admin;

import com.yeyks.account.dal.domain.AccountInfo;
import com.yeyks.common.appcommon.dto.AppMessageDTO;
import com.yeyks.common.appcommon.dto.account.AppAccountDTO;
import com.yeyks.common.appcommon.dto.account.AppIndexDTO;
import com.yeyks.common.appcommon.dto.order.AppOrderInfoDTO;
import com.yeyks.common.appcommon.param.QueryStatFeeParam;
import com.yeyks.common.appcommon.param.order.GetOrderNoticeParam;
import com.yeyks.common.appcommon.param.room.GetInRoomNoticeParam;
import com.yeyks.common.appcommon.result.CommonPage;
import com.yeyks.common.appcommon.result.CommonResult;
import com.yeyks.common.utils.apputil.bean.MyBeanUtils;
import com.yeyks.commonReference.service.message.MessageService;
import com.yeyks.commonReference.service.order.OrderHeadService;
import com.yeyks.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.List;

/**
 * @author Administrator
 */
@Api(tags = "AppMainController_首页接口", description = "首页相关的接口")
@RestController
@RequestMapping("/admin/main")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class AppMainController extends BaseController {


    private final OrderHeadService orderHeadService;

    private final MessageService messageService;

    @ApiOperation("获取今日总金额, 订单数, 新增酒店等数据")
    @PostMapping("/get")
    public CommonResult<List<AppIndexDTO>> getIndexData(@Valid QueryStatFeeParam queryStatFeeParam){

        AppAccountDTO appAccountDTO = this.validToken(queryStatFeeParam.getToken(),
                queryStatFeeParam.getVersion(), queryStatFeeParam.getPlatform());
        //得到当天日期的时间戳 0点到24点, '%Y-%c-%d'

        return orderHeadService.statFeeByAdminAppIndex(queryStatFeeParam,
                MyBeanUtils.convert(appAccountDTO, AccountInfo.class));
    }

    @ApiOperation("获取入住通知消息")
    @PostMapping("/get/notice")
    public CommonResult<CommonPage<AppMessageDTO>> getInRoomNotice(@Valid GetInRoomNoticeParam getInRoomNoticeParam){

        AppAccountDTO appAccountDTO = this.validToken(getInRoomNoticeParam.getToken(),
                getInRoomNoticeParam.getVersion(), getInRoomNoticeParam.getPlatform());

        return messageService.getInRoomNotice(getInRoomNoticeParam,
                MyBeanUtils.convert(appAccountDTO, AccountInfo.class));
    }


    @ApiOperation("获取接单信息")
    @PostMapping("/get/order")
    public CommonResult<CommonPage<AppOrderInfoDTO>> getOrderNotice(@Valid GetOrderNoticeParam getOrderNoticeParam){

        AppAccountDTO appAccountDTO = this.validToken(getOrderNoticeParam.getToken(),
                getOrderNoticeParam.getVersion(), getOrderNoticeParam.getPlatform());

        return orderHeadService.getOrderNotice(getOrderNoticeParam,
                MyBeanUtils.convert(appAccountDTO, AccountInfo.class));
    }




}
